# coding:utf-8

class Item(object):
    def __init__(self):
        
        self.id = ''    # UUID
        self.owner = ''    # 所有者 UUID
        self.type = 0    # 种类
        self.amount = 0    # 数量

    # 转化成字典数据
    def to_dictionary(self):
        import copy
        return copy.deepcopy(self.__dict__) # 类比较干净,直接传__dict__就行了

    def from_dictionary(self, d):
        for k in self.get_prop_names():
            if k in d:
                setattr(self, k, d[k])

    def get_prop_names(self):
        return self.__dict__.keys()


    def __repr__(self):
        return '<Item(%s,%d)>' % (self.type, self.amount)


